home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / TranslationExtensions.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  6KB  |  178 lines

  1. /*
  2.      File:        TranslationExtensions.h
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __TRANSLATIONEXTENSIONS__
  19. #define __TRANSLATIONEXTENSIONS__
  20.  
  21. #define kSupportsFileTranslation        1
  22. #define kSupportsScrapTranslation        2
  23. #define kTranslatorCanGenerateFilename    4
  24.  
  25. #ifndef REZ
  26. #ifndef __MEMORY__
  27. #include <Memory.h>
  28. #endif
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35. #ifndef __COMPONENTS__
  36. #include <Components.h>
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT_SUPPORTED
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_ALIGN_SUPPORTED
  48. #pragma options align=mac68k
  49. #endif
  50.  
  51. /* better names for 4-char codes*/
  52. typedef OSType FileType;
  53. typedef ResType ScrapType;
  54. typedef unsigned long TranslationAttributes;
  55.  
  56. enum {
  57.     taDstDocNeedsResourceFork    = 1,
  58.     taDstIsAppTranslation        = 2
  59. };
  60.  
  61. struct FileTypeSpec {
  62.     FileType                         format;
  63.     long                             hint;
  64.     TranslationAttributes             flags;                        /* taDstDocNeedsResourceFork, taDstIsAppTranslation*/
  65.     OSType                             catInfoType;
  66.     OSType                             catInfoCreator;
  67. };
  68. typedef struct FileTypeSpec FileTypeSpec;
  69.  
  70. struct FileTranslationList {
  71.     unsigned long                     modDate;
  72.     unsigned long                     groupCount;
  73.                                                                 /*     unsigned long    group1SrcCount;*/
  74.                                                                 /*     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);*/
  75.                                                                 /*  FileTypeSpec    group1SrcTypes[group1SrcCount]*/
  76.                                                                 /*  unsigned long    group1DstCount;*/
  77.                                                                 /*  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);*/
  78.                                                                 /*  FileTypeSpec    group1DstTypes[group1DstCount]*/
  79. };
  80. typedef struct FileTranslationList FileTranslationList;
  81.  
  82. typedef FileTranslationList *FileTranslationListPtr;
  83. typedef FileTranslationListPtr *FileTranslationListHandle;
  84. struct ScrapTypeSpec {
  85.     ScrapType                         format;
  86.     long                             hint;
  87. };
  88. typedef struct ScrapTypeSpec ScrapTypeSpec;
  89.  
  90. struct ScrapTranslationList {
  91.     unsigned long                     modDate;
  92.     unsigned long                     groupCount;
  93.                                                                 /*     unsigned long        group1SrcCount;*/
  94.                                                                 /*     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);*/
  95.                                                                 /*  ScrapTypeSpec        group1SrcTypes[group1SrcCount]*/
  96.                                                                 /*  unsigned long        group1DstCount;*/
  97.                                                                 /*     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);*/
  98.                                                                 /*  ScrapTypeSpec        group1DstTypes[group1DstCount]*/
  99. };
  100. typedef struct ScrapTranslationList ScrapTranslationList;
  101.  
  102. typedef ScrapTranslationList *ScrapTranslationListPtr;
  103. typedef ScrapTranslationListPtr *ScrapTranslationListHandle;
  104. /* definition of callbacks to update progress dialog*/
  105. typedef long TranslationRefNum;
  106. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  107. /*
  108. ****************************************************************************************
  109. *
  110. * This routine sets the advertisement in the top half of the progress dialog.
  111. * It is called once at the beginning of your DoTranslateFile routine.
  112. *
  113. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  114. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  115. *                            Before returning from DoTranslateFile, you should dispose
  116. *                            of the memory.  (Normally, it is in the temp translation heap
  117. *                            so it is cleaned up for you.)
  118. *
  119. * Exit:    returns            noErr, paramErr, or memFullErr
  120. */
  121. extern pascal OSErr SetTranslationAdvertisement(TranslationRefNum refNum, PicHandle advertisement)
  122.  TWOWORDINLINE(0x7002, 0xABFC);
  123.  
  124. /*
  125. ****************************************************************************************
  126. *
  127. * This routine updates the progress bar in the progress dialog.
  128. * It is called repeatedly from within your DoTranslateFile routine.
  129. * It should be called often, so that the user will get feedback if he tries to cancel.
  130. *
  131. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  132. *            progress    percent complete (0-100)
  133. *
  134. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  135. *            returns        noErr, paramErr, or memFullErr
  136. */
  137. extern pascal OSErr UpdateTranslationProgress(TranslationRefNum refNum, short percentDone, Boolean *canceled)
  138.  TWOWORDINLINE(0x7001, 0xABFC);
  139.  
  140. /* ComponentMgr selectors for routines*/
  141.  
  142. enum {
  143.     kTranslateGetFileTranslationList = 0,                        /* component selectors*/
  144.     kTranslateIdentifyFile        = 1,
  145.     kTranslateTranslateFile        = 2,
  146.     kTranslateGetTranslatedFilename = 3,
  147.     kTranslateGetScrapTranslationList = 10,                        /* skip to scrap routines*/
  148.     kTranslateIdentifyScrap        = 11,
  149.     kTranslateTranslateScrap    = 12
  150. };
  151.  
  152. /* Routines to implment in a file translation extension*/
  153. typedef pascal ComponentResult (*DoGetFileTranslationListProcPtr)(ComponentInstance self, FileTranslationListHandle translationList);
  154. typedef pascal ComponentResult (*DoIdentifyFileProcPtr)(ComponentInstance self, const FSSpec *theDocument, FileType *docType);
  155. typedef pascal ComponentResult (*DoTranslateFileProcPtr)(ComponentInstance self, TranslationRefNum refNum, const FSSpec *sourceDocument, FileType srcType, long srcTypeHint, const FSSpec *dstDoc, FileType dstType, long dstTypeHint);
  156. typedef pascal ComponentResult (*DoGetTranslatedFilenameProcPtr)(ComponentInstance self, FileType dstType, long dstTypeHint, FSSpec *theDocument);
  157. /* Routine to implement in a scrap translation extension*/
  158. typedef pascal ComponentResult (*DoGetScrapTranslationListProcPtr)(ComponentInstance self, ScrapTranslationListHandle list);
  159. typedef pascal ComponentResult (*DoIdentifyScrapProcPtr)(ComponentInstance self, const void *dataPtr, Size dataLength, ScrapType *dataFormat);
  160. typedef pascal ComponentResult (*DoTranslateScrapProcPtr)(ComponentInstance self, TranslationRefNum refNum, const void *srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint, Handle dstData, ScrapType dstType, long dstTypeHint);
  161. #endif
  162. #endif /* REZ */
  163.  
  164. #if PRAGMA_ALIGN_SUPPORTED
  165. #pragma options align=reset
  166. #endif
  167.  
  168. #if PRAGMA_IMPORT_SUPPORTED
  169. #pragma import off
  170. #endif
  171.  
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175.  
  176. #endif /* __TRANSLATIONEXTENSIONS__ */
  177.  
  178.